<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="150px">
      <el-form-item label="订单号" prop="orderCode">
        <el-input v-model="queryParams.orderCode" placeholder="请输入订单号"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户ID" prop="orderUserid">
        <el-input v-model="queryParams.orderUserid" placeholder="请输入用户ID"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="被服务人信息ID" prop="orderServedid">
        <el-input v-model="queryParams.orderServedid" placeholder="请输入被服务人信息ID"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="服务地址ID" prop="orderAddressid">
        <el-input v-model="queryParams.orderAddressid" placeholder="请输入服务地址ID"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="分配护士ID" prop="orderNurseid">
        <el-input v-model="queryParams.orderNurseid" placeholder="请输入分配护士ID"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="支付信息表ID" prop="orderPay">
        <el-input v-model="queryParams.orderPay" placeholder="请输入支付信息表ID"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单时间信息表ID" prop="orderTime">
        <el-input v-model="queryParams.orderTime" placeholder="请输入订单时间信息表ID"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      ：0生效 1已取消 2退款中 3已退款 4关闭-->
      <el-form-item label="订单生效状态" prop="orderFlag">
        <el-select v-model="queryParams.orderFlag" placeholder="请选择订单生效状态：0生效 1已取消 2退款中 3已退款 4关闭"
                   clearable
        >
          <el-option v-for="dict in dict.type.service_order_flag" :key="dict.value"
                     :label="dict.label" :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <!--      ：0正常 异常：1超时预警(派单)：待服务 2超时预警(接单)：待服务 3超时未开始：待服务 4超时未结束服务：服务中 5超时未提交结算：服务中 6超时未结算尾款：结算中-->
      <el-form-item label="订单是否异常" prop="orderStatus">
        <el-select v-model="queryParams.orderStatus"
                   placeholder="请选择订单是否异常：0正常 异常：1超时预警(派单)：待服务 2超时预警(接单)：待服务 3超时未开始：待服务 4超时未结束服务：服务中 5超时未提交结算：服务中 6超时未结算尾款：结算中"
                   clearable
        >
          <el-option v-for="dict in dict.type.service_order_status" :key="dict.value"
                     :label="dict.label" :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <!--      :1-creat-创建,2-cancel-取消,3-audit_cancel-审核取消,4-canceled-已取消,5-report-上报,6-header_assign-护理部已分配,7-assign-已分配,8-receive-已接受,9-departure-已出发,10-arrival-已到达,11-pat_audit-服务完成,12-finish-订单完成,13-comment-已评价-->
      <el-form-item label="订单服务状态" prop="orderServiceflag">
        <el-select v-model="queryParams.orderServiceflag"
                   placeholder="请选择订单服务状态:1-creat-创建,2-cancel-取消,3-audit_cancel-审核取消,4-canceled-已取消,5-report-上报,6-header_assign-护理部已分配,7-assign-已分配,8-receive-已接受,9-departure-已出发,10-arrival-已到达,11-pat_audit-服务完成,12-finish-订单完成,13-comment-已评价"
                   clearable
        >
          <el-option v-for="dict in dict.type.service_order_service_flag" :key="dict.value"
                     :label="dict.label" :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="订单创建时间">
        <el-date-picker v-model="daterangeOrderCreatetime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="预定上门时间">
        <el-date-picker v-model="daterangeOrderScheduledtime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="实际上门时间">
        <el-date-picker v-model="daterangeOrderActuallydoortime" style="width: 240px"
                        value-format="yyyy-MM-dd" type="daterange" range-separator="-"
                        start-placeholder="开始日期" end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="订单完成时间">
        <el-date-picker v-model="daterangeOrderEndtime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="订单评价表ID" prop="orderAssessmentid">
        <el-input v-model="queryParams.orderAssessmentid" placeholder="请输入订单评价表ID"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单关闭原因表ID" prop="orderReasonstopid">
        <el-input v-model="queryParams.orderReasonstopid" placeholder="请输入订单关闭原因表ID"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单关闭补充说明" prop="orderReasonremark">
        <el-input v-model="queryParams.orderReasonremark" placeholder="请输入订单关闭补充说明"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建者" prop="orderCreateBy">
        <el-input v-model="queryParams.orderCreateBy" placeholder="请输入创建者" clearable
                  @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker v-model="daterangeOrderCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="更新者" prop="orderUpdateBy">
        <el-input v-model="queryParams.orderUpdateBy" placeholder="请输入更新者"
                  clearable @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="更新时间">
        <el-date-picker v-model="daterangeOrderUpdateTime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange"
                        range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="启用标志" prop="orderUseFlag">
        <el-select v-model="queryParams.orderUseFlag" placeholder="请选择启用标志" clearable>
          <el-option v-for="dict in dict.type.service_yes_no" :key="dict.value"
                     :label="dict.label" :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="删除标志" prop="orderDelFlag">
        <el-select v-model="queryParams.orderDelFlag" placeholder="请选择删除标志" clearable>
          <el-option v-for="dict in dict.type.service_yes_no" :key="dict.value"
                     :label="dict.label" :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="备注" prop="orderRemark">
        <el-input v-model="queryParams.orderRemark" placeholder="请输入备注" clearable
                  @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini"
                   @click="handleAdd" v-hasPermi="['service:orders:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single"
                   @click="handleUpdate" v-hasPermi="['service:orders:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
                   @click="handleDelete" v-hasPermi="['service:orders:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini"
                   @click="handleExport" v-hasPermi="['service:orders:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="ordersList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="订单主键ID" align="center" prop="orderId"/>
      <el-table-column label="订单号" align="center" prop="orderCode"/>
      <el-table-column label="用户ID" align="center" prop="orderUserid"/>
      <el-table-column label="被服务人信息ID" align="center" prop="orderServedid"/>
      <el-table-column label="服务地址ID" align="center" prop="orderAddressid"/>
      <el-table-column label="分配护士ID" align="center" prop="orderNurseid"/>
      <el-table-column label="支付信息表ID" align="center" prop="orderPay"/>
      <el-table-column label="订单时间信息表ID" align="center" prop="orderTime"/>
      <!--      ：0生效 1已取消 2退款中 3已退款 4关闭-->
      <el-table-column label="订单生效状态" align="center" prop="orderFlag">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.service_order_flag" :value="scope.row.orderFlag"/>
        </template>
      </el-table-column>
      <!--      ：0正常 异常：1超时预警(派单)：待服务 2超时预警(接单)：待服务 3超时未开始：待服务 4超时未结束服务：服务中 5超时未提交结算：服务中 6超时未结算尾款：结算中-->
      <el-table-column label="订单是否异常" align="center" prop="orderStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.service_order_status" :value="scope.row.orderStatus"/>
        </template>
      </el-table-column>
      <!--      :1-creat-创建,2-cancel-取消,3-audit_cancel-审核取消,4-canceled-已取消,5-report-上报,6-header_assign-护理部已分配,7-assign-已分配,8-receive-已接受,9-departure-已出发,10-arrival-已到达,11-pat_audit-服务完成,12-finish-订单完成,13-comment-已评价-->
      <el-table-column label="订单服务状态" align="center" prop="orderServiceflag">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.service_order_service_flag" :value="scope.row.orderServiceflag"/>
        </template>
      </el-table-column>
      <el-table-column label="订单创建时间" align="center" prop="orderCreatetime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderCreatetime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="预定上门时间" align="center" prop="orderScheduledtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderScheduledtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际上门时间" align="center" prop="orderActuallydoortime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderActuallydoortime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="订单完成时间" align="center" prop="orderEndtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderEndtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="订单评价表ID" align="center" prop="orderAssessmentid"/>
      <el-table-column label="订单预约备注" align="center" prop="orderServiceremark"/>
      <el-table-column label="订单结算护士备注" align="center" prop="orderNurseremark"/>
      <el-table-column label="订单关闭原因表ID" align="center" prop="orderReasonstopid"/>
      <el-table-column label="订单关闭补充说明" align="center" prop="orderReasonremark"/>
      <el-table-column label="创建者" align="center" prop="orderCreateBy"/>
      <el-table-column label="创建时间" align="center" prop="orderCreateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderCreateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新者" align="center" prop="orderUpdateBy"/>
      <el-table-column label="更新时间" align="center" prop="orderUpdateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderUpdateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="启用标志" align="center" prop="orderUseFlag">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.service_yes_no" :value="scope.row.orderUseFlag"/>
        </template>
      </el-table-column>
      <el-table-column label="删除标志" align="center" prop="orderDelFlag">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.service_yes_no" :value="scope.row.orderDelFlag"/>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="orderRemark"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['service:orders:edit']"
          >修改
          </el-button>
          <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['service:orders:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />

    <!-- 添加或修改订单信息表对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="订单号" prop="orderCode">
          <el-input v-model="form.orderCode" placeholder="请输入订单号"/>
        </el-form-item>
        <el-form-item label="用户ID" prop="orderUserid">
          <el-input v-model="form.orderUserid" placeholder="请输入用户ID"/>
        </el-form-item>
        <el-form-item label="被服务人信息ID" prop="orderServedid">
          <el-input v-model="form.orderServedid" placeholder="请输入被服务人信息ID"/>
        </el-form-item>
        <el-form-item label="服务地址ID" prop="orderAddressid">
          <el-input v-model="form.orderAddressid" placeholder="请输入服务地址ID"/>
        </el-form-item>
        <el-form-item label="分配护士ID" prop="orderNurseid">
          <el-input v-model="form.orderNurseid" placeholder="请输入分配护士ID"/>
        </el-form-item>
        <el-form-item label="支付信息表ID" prop="orderPay">
          <el-input v-model="form.orderPay" placeholder="请输入支付信息表ID"/>
        </el-form-item>
        <el-form-item label="订单时间信息表ID" prop="orderTime">
          <el-input v-model="form.orderTime" placeholder="请输入订单时间信息表ID"/>
        </el-form-item>
        <el-form-item label="订单生效状态" prop="orderFlag">
          <el-select v-model="form.orderFlag" placeholder="请选择订单生效状态：0生效 1已取消 2退款中 3已退款 4关闭">
            <el-option
                v-for="dict in dict.type.service_order_flag"
                :key="dict.value"
                :label="dict.label"
                :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="订单是否异常" prop="orderStatus">
          <el-select v-model="form.orderStatus"
                     placeholder="请选择订单是否异常：0正常 异常：1超时预警(派单)：待服务 2超时预警(接单)：待服务 3超时未开始：待服务 4超时未结束服务：服务中 5超时未提交结算：服务中 6超时未结算尾款：结算中"
          >
            <el-option
                v-for="dict in dict.type.service_order_status"
                :key="dict.value"
                :label="dict.label"
                :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="订单服务状态" prop="orderServiceflag">
          <el-select v-model="form.orderServiceflag"
                     placeholder="请选择订单服务状态:1-creat-创建,2-cancel-取消,3-audit_cancel-审核取消,4-canceled-已取消,5-report-上报,6-header_assign-护理部已分配,7-assign-已分配,8-receive-已接受,9-departure-已出发,10-arrival-已到达,11-pat_audit-服务完成,12-finish-订单完成,13-comment-已评价"
          >
            <el-option
                v-for="dict in dict.type.service_order_service_flag"
                :key="dict.value"
                :label="dict.label"
                :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="订单创建时间" prop="orderCreatetime">
          <el-date-picker clearable
                          v-model="form.orderCreatetime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择订单创建时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="预定上门时间" prop="orderScheduledtime">
          <el-date-picker clearable
                          v-model="form.orderScheduledtime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择预定上门时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="实际上门时间" prop="orderActuallydoortime">
          <el-date-picker clearable
                          v-model="form.orderActuallydoortime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择实际上门时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="订单完成时间" prop="orderEndtime">
          <el-date-picker clearable
                          v-model="form.orderEndtime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择订单完成时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="订单评价表ID" prop="orderAssessmentid">
          <el-input v-model="form.orderAssessmentid" placeholder="请输入订单评价表ID"/>
        </el-form-item>
        <el-form-item label="订单预约备注" prop="orderServiceremark">
          <el-input v-model="form.orderServiceremark" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
        <el-form-item label="订单结算护士备注" prop="orderNurseremark">
          <el-input v-model="form.orderNurseremark" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
        <el-form-item label="订单关闭原因表ID" prop="orderReasonstopid">
          <el-input v-model="form.orderReasonstopid" placeholder="请输入订单关闭原因表ID"/>
        </el-form-item>
        <el-form-item label="订单关闭补充说明" prop="orderReasonremark">
          <el-input v-model="form.orderReasonremark" placeholder="请输入订单关闭补充说明"/>
        </el-form-item>
        <el-form-item label="创建者" prop="orderCreateBy">
          <el-input v-model="form.orderCreateBy" placeholder="请输入创建者"/>
        </el-form-item>
        <el-form-item label="创建时间" prop="orderCreateTime">
          <el-date-picker clearable
                          v-model="form.orderCreateTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择创建时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="更新者" prop="orderUpdateBy">
          <el-input v-model="form.orderUpdateBy" placeholder="请输入更新者"/>
        </el-form-item>
        <el-form-item label="更新时间" prop="orderUpdateTime">
          <el-date-picker clearable
                          v-model="form.orderUpdateTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择更新时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="启用标志" prop="orderUseFlag">
          <el-select v-model="form.orderUseFlag" placeholder="请选择启用标志">
            <el-option
                v-for="dict in dict.type.service_yes_no"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="删除标志" prop="orderDelFlag">
          <el-select v-model="form.orderDelFlag" placeholder="请选择删除标志">
            <el-option
                v-for="dict in dict.type.service_yes_no"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="orderRemark">
          <el-input v-model="form.orderRemark" placeholder="请输入备注"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listOrders, getOrders, delOrders, addOrders, updateOrders } from '@/api/service/orders'

export default {
  name: 'Orders',
  dicts: ['service_order_service_flag', 'service_order_status', 'service_yes_no', 'service_order_flag'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 订单信息表表格数据
      ordersList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 备注时间范围
      daterangeOrderCreatetime: [],
      // 备注时间范围
      daterangeOrderScheduledtime: [],
      // 备注时间范围
      daterangeOrderActuallydoortime: [],
      // 备注时间范围
      daterangeOrderEndtime: [],
      // 备注时间范围
      daterangeOrderCreateTime: [],
      // 备注时间范围
      daterangeOrderUpdateTime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderCode: null,
        orderUserid: null,
        orderServedid: null,
        orderAddressid: null,
        orderNurseid: null,
        orderPay: null,
        orderTime: null,
        orderFlag: null,
        orderStatus: null,
        orderServiceflag: null,
        orderCreatetime: null,
        orderScheduledtime: null,
        orderActuallydoortime: null,
        orderEndtime: null,
        orderAssessmentid: null,
        orderServiceremark: null,
        orderNurseremark: null,
        orderReasonstopid: null,
        orderReasonremark: null,
        orderCreateBy: null,
        orderCreateTime: null,
        orderUpdateBy: null,
        orderUpdateTime: null,
        orderUseFlag: null,
        orderDelFlag: null,
        orderRemark: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        orderCode: [
          { required: true, message: '订单号不能为空', trigger: 'blur' }
        ],
        orderUserid: [
          { required: true, message: '用户ID不能为空', trigger: 'blur' }
        ],
        orderFlag: [
          { required: true, message: '订单生效状态：0生效 1已取消 2退款中 3已退款 4关闭不能为空', trigger: 'change' }
        ]
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询订单信息表列表 */
    getList() {
      this.loading = true
      this.queryParams.params = {}
      if (null != this.daterangeOrderCreatetime && '' != this.daterangeOrderCreatetime) {
        this.queryParams.params['beginOrderCreatetime'] = this.daterangeOrderCreatetime[0]
        this.queryParams.params['endOrderCreatetime'] = this.daterangeOrderCreatetime[1]
      }
      if (null != this.daterangeOrderScheduledtime && '' != this.daterangeOrderScheduledtime) {
        this.queryParams.params['beginOrderScheduledtime'] = this.daterangeOrderScheduledtime[0]
        this.queryParams.params['endOrderScheduledtime'] = this.daterangeOrderScheduledtime[1]
      }
      if (null != this.daterangeOrderActuallydoortime && '' != this.daterangeOrderActuallydoortime) {
        this.queryParams.params['beginOrderActuallydoortime'] = this.daterangeOrderActuallydoortime[0]
        this.queryParams.params['endOrderActuallydoortime'] = this.daterangeOrderActuallydoortime[1]
      }
      if (null != this.daterangeOrderEndtime && '' != this.daterangeOrderEndtime) {
        this.queryParams.params['beginOrderEndtime'] = this.daterangeOrderEndtime[0]
        this.queryParams.params['endOrderEndtime'] = this.daterangeOrderEndtime[1]
      }
      if (null != this.daterangeOrderCreateTime && '' != this.daterangeOrderCreateTime) {
        this.queryParams.params['beginOrderCreateTime'] = this.daterangeOrderCreateTime[0]
        this.queryParams.params['endOrderCreateTime'] = this.daterangeOrderCreateTime[1]
      }
      if (null != this.daterangeOrderUpdateTime && '' != this.daterangeOrderUpdateTime) {
        this.queryParams.params['beginOrderUpdateTime'] = this.daterangeOrderUpdateTime[0]
        this.queryParams.params['endOrderUpdateTime'] = this.daterangeOrderUpdateTime[1]
      }
      listOrders(this.queryParams).then(response => {
        this.ordersList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        orderId: null,
        orderCode: null,
        orderUserid: null,
        orderServedid: null,
        orderAddressid: null,
        orderNurseid: null,
        orderPay: null,
        orderTime: null,
        orderFlag: null,
        orderStatus: null,
        orderServiceflag: null,
        orderCreatetime: null,
        orderScheduledtime: null,
        orderActuallydoortime: null,
        orderEndtime: null,
        orderAssessmentid: null,
        orderServiceremark: null,
        orderNurseremark: null,
        orderReasonstopid: null,
        orderReasonremark: null,
        orderCreateBy: null,
        orderCreateTime: null,
        orderUpdateBy: null,
        orderUpdateTime: null,
        orderUseFlag: null,
        orderDelFlag: null,
        orderRemark: null
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeOrderCreatetime = []
      this.daterangeOrderScheduledtime = []
      this.daterangeOrderActuallydoortime = []
      this.daterangeOrderEndtime = []
      this.daterangeOrderCreateTime = []
      this.daterangeOrderUpdateTime = []
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.orderId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '添加订单信息表'
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const orderId = row.orderId || this.ids
      getOrders(orderId).then(response => {
        this.form = response.data
        this.open = true
        this.title = '修改订单信息表'
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (this.form.orderId != null) {
            updateOrders(this.form).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.open = false
              this.getList()
            })
          } else {
            addOrders(this.form).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const orderIds = row.orderId || this.ids
      this.$modal.confirm('是否确认删除订单信息表编号为"' + orderIds + '"的数据项？').then(function() {
        return delOrders(orderIds)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('service/orders/export', {
        ...this.queryParams
      }, `orders_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
